import axios from 'axios'
import { Toast } from 'vant';
const instance = axios.create({
    baseURL:'https://www.ahsj.link/nebula-api',
    timeout:5000
})
instance.interceptors.request.use(config=>{
    if(config.url==='/api/message/updates'){
        config.headers  ={
            "Content-Type": 'application/x-www-form-urlencode',
        }
    }
    let token =localStorage.getItem('token')
    if(token){
 config.headers['x-auth-token'] = token
    }
        return config
},err=>{
    return Promise.reject(err)
})
instance.interceptors.response.use(result=>{
    return result.data
},err=>{
    Toast.fail('账号或密码错误');
    return Promise.reject(err)
})


export default instance